<template>
	<view class="kickback_record_container">
		<view class="kickback_record_box" v-if="fxuserDataList.length !==0">
			<!-- top -->
			<view class="detail_top_box">
				<view class="top_total_box">
					总计<span class="top_total_num">{{countAll}}</span><span class="top_total_unit">(单)</span>
				</view>
			</view>

			<view class="kickback_record_all" v-for="(item, index) in fxuserDataList" :key="index">
				<view class="kickback_top_box">
					<view class="kickback_top_tip">
						佣金来源：<span v-if="item.source == '0'">代理分佣</span>
						<span v-else-if="item.source == '1'">合伙人分佣</span>
						<span v-else-if="item.source == '2'">分销员分佣</span>
						<span v-else-if="item.source == '3'">提现</span>
					</view>
					<view class="kickback_top_date">
						时间：<span style="font-family: my-font;">{{ item.created_at }}</span>
					</view>
				</view>
				<view class="kickback_bottom_box">
					<view class="kickback_bottom_order">
						{{ item.order_no }}
					</view>
					<view class=""
						:class="[item.status == '0' ? 'kickback_bottom_num_up' : 'kickback_bottom_num_down']">
						<span>{{item.status == '0' ? '+' : '-'}}</span>{{ item.balance }}
					</view>
				</view>
			</view>
		</view>

		<!-- 没有订单 -->
		<view class="kickback_record_no_box" v-else>
			您还未获得佣金，快去推广吧~
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				fxuserDataList: [],
				dataType: '',
				countAll: '',
				pageObj: {
					pageNow: 1,
					pageSize: 10
				},
				total: 0
			}
		},
		onShow() {
			
		},
		onLoad(option) {
			this.dataType = option.type
			this.countAll = option.countAll
			this.getAgentDataCount()
		},
		onReachBottom() {
			if (this.pageObj.pageNow < this.total) {
				this.pageObj.pageNow++
				this.getAgentDataCount()
			} else if (this.pageObj.pageNow == this.total) {
				uni.showToast({
					title: '暂无更多数据',
					icon: 'none'
				})
				return
			}
		},
		methods: {
			// 数据统计接口
			getAgentDataCount() {
				this.$request('/api/getAgentDataCount', {
					type: this.dataType,
					page_now: this.pageObj.pageNow,
					page_size: this.pageObj.pageSize
				}, 'GET').then(res => {
					if (res.code == 1) {
						res.data.forEach(item => {
							this.fxuserDataList.push(item)
						})
						this.total = res.page_info.page_count
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						return
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.kickback_record_container {
		padding: 16rpx 20rpx 0;

		.kickback_record_box {

			.detail_top_box {
				display: flex;
				justify-content: center;
				background: #FFFFFF;
				border-radius: 8rpx;
				padding: 32rpx 0 34rpx;
				margin-bottom: 14rpx;

				.top_total_box {
					font-family: all-font;
					font-weight: 400;
					font-size: 20rpx;
					color: #333333;

					.top_total_num {
						font-family: my-font;
						font-weight: bold;
						font-size: 58rpx;
						color: #333333;
					}

					.top_total_unit {
						font-family: my-font;
						font-size: 24rpx;
					}
				}

				.top_compare_box {
					display: flex;
					align-items: center;
					height: 31rpx;
					background: #F2F2F2;
					border-radius: 15rpx;
					padding: 0 18rpx;

					.top_compare_yesterday {
						font-family: Source Han Sans CN;
						font-weight: 400;
						font-size: 20rpx;
						color: #808080;
						padding: 0 8rpx;

						.top_compare_num {
							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 21rpx;
							color: #00C580;
						}
					}

					.top_compare_down {
						width: 0;
						height: 0;
						border-left: 10rpx solid transparent;
						border-right: 10rpx solid transparent;
						border-top: 10rpx solid #00C580;
					}

					.top_compare_up {
						width: 0;
						height: 0;
						border-top: 0 solid transparent;
						border-right: 10rpx solid transparent;
						border-left: 10rpx solid transparent;
						border-bottom: 10rpx solid #FF2B2B;
					}
				}
			}

			.kickback_record_all {
				background: #FFFFFF;
				box-shadow: 0px 5rpx 4rpx 0px rgba(244, 244, 244, 0.54);
				border-radius: 12rpx;
				padding: 18rpx 23rpx 22rpx 31rpx;
				margin-bottom: 12rpx;

				.kickback_top_box {
					display: flex;
					justify-content: space-between;

					.kickback_top_tip {
						background: #FFF4F4;
						border-radius: 6rpx;
						font-family: all-font;
						font-weight: 400;
						font-size: 26rpx;
						color: #FF2E2E;
						padding: 4rpx 14rpx;
					}

					.kickback_top_date {
						font-family: all-font;
						font-weight: normal;
						font-size: 24rpx;
						color: #808080;
					}
				}

				.kickback_bottom_box {
					display: flex;
					justify-content: space-between;
					padding-top: 39rpx;

					.kickback_bottom_order {
						font-family: my-font;
						font-weight: 500;
						font-size: 30rpx;
						color: #333333;
					}

					.kickback_bottom_num_down {
						font-family: my-font;
						font-weight: 500;
						font-size: 28rpx;
						color: #00c482;
					}

					.kickback_bottom_num_up {
						font-family: my-font;
						font-weight: 500;
						font-size: 28rpx;
						color: #FF1B1B;
					}
				}
			}
		}


		.kickback_record_no_box {
			font-size: 40rpx;
			font-family: all-font;
			color: #ccc;
			text-align: center;
			padding-top: 30rpx;
		}
	}
</style>